package com.yeswater.multithread.chapter6;

/**
 * author : yeswater
 * date : 2023/10/24
 */

public class Run_6_1_1 {
    public static void main(String[] args) {
        MyThread t1 = new MyThread();
        MyThread t2 = new MyThread();
        MyThread t3 = new MyThread();

        t1.start();
        t2.start();
        t3.start();
    }

    private static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println(MyObject.getInstance().hashCode());
        }
    }

    private static class MyObject {
        private static final MyObject myObject = new MyObject();
        private static String username;
        private static String password;

        private MyObject() {

        }

        public static MyObject getInstance() {
            username = "1";  // 从不同的服务器取出值(可能不一样),并赋值
            password = "2";  // 从不同的服务器取出值(可能不一样),并赋值
            return myObject;
        }
    }
}
